-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run doctests in pytest. Add linters to pre-commit. Add a pre-commit workflow. #96
Run doctests in pytest. Add linters to pre-commit. Add a pre-commit workflow. #96
Conversation
aliddell
commented
Oct 6, 2023
•
edited
Loading
edited
- Adds doctests for pyi and md files.
- Pulls pytest arguments used in build / test workflows into pyproject.toml.
- Adds ruff and rustfmt checks to pre-commit.
- Adds a pre-commit check workflow that runs on PRs into main.
a48ca40
to
03245c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
I know you've got a question for @andy-sweet and I wonder about other things to get into the pre commit (e.g. ruff
and cargo fmt
). So feel free to hold off on merging till you're comfortable. But I think this can go in as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running doctests as part of pre-commit feels a bit heavy to me (e.g. compared to linting), especially when those tests depend on locally connected hardware.
I think that pytest should just pick up on any doctests in Python modules by default and we can modify the glob pattern to also look at the Markdown files (and Rust files if needed). In that case, we don't need to add any new workflows either (though adding a remote pre-commit might be a good idea).
I added a check on the .pyi files to test_docs.py and removed the pre-commit check, opting to just call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good, but I don't think we need to explicitly collect doctests with test_docs.py
, in which case we can and should make a few simplifications.
…te pytest args in workflow files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is mostly about adding code format checkers to pre-commit (and the resulting changes that causes) than it is about running the tests on documented examples.
I'm fine with that (i.e. no need to split the PR), but at least update the title and description to match that.
exclude = [ | ||
"__init__.py" | ||
] | ||
|
||
ignore = [ | ||
"F403", | ||
"F405", | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK to start with these excludes and ignores, though I'd prefer to have none of them in the long term.